package com.lxl.demo01.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lxl.demo01.dao.DoAlertMapper;
import com.lxl.demo01.domain.DayDTO;
import com.lxl.demo01.domain.DoAlert;
import com.lxl.demo01.domain.MonthDTO;
import com.lxl.demo01.domain.WeekDTO;
import com.lxl.demo01.service.IDoAlertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 快速开发服务层（基于MP）
 * ServiceImpl<实现类，模型类>
 */
@Service  // 这是业务层
public class DoAlertServiceImpl extends ServiceImpl<DoAlertMapper, DoAlert> implements IDoAlertService {
    // 这就做完了DoAlertService和DoAlertServiceImplPub的内容。自动完成调用dao层操作数据库

    // 实现自定义的方法
    @Autowired
    private DoAlertMapper doAlertMapper;

    @Override
    public IPage<DoAlert> getPage(int currentPage, int pageSize) {
        Page<DoAlert> page = new Page<>(currentPage, pageSize);
        doAlertMapper.selectPage(page, null);
        return page;
    }

    @Override
    public List<DayDTO> selectDay() {
        // 调用DAO层方法
        List<DayDTO> dayDTOS = doAlertMapper.selectDay();
        return dayDTOS;
    }

    @Override
    public List<MonthDTO> selectMonth() {
        List<MonthDTO> monthDTOS = doAlertMapper.selectMonth();
        return monthDTOS;
    }

    @Override
    public List<WeekDTO> selectWeek() {
        List<WeekDTO> weekDTOS = doAlertMapper.selectWeek();
        return weekDTOS;
    }

    @Override
    public List<DayDTO> getDayPage(Integer monitor_type, Integer currentPage, Integer pageSize) {
        List<DayDTO> dayDTOS = doAlertMapper.selectDayPage(monitor_type, currentPage, pageSize);
        return dayDTOS;
    }

    @Override
    public List<MonthDTO> getMonthPage(Integer monitor_type, Integer currentPage, Integer pageSize) {
        return doAlertMapper.selectMonthPage(monitor_type, currentPage, pageSize);
    }

    @Override
    public List<WeekDTO> getWeekPage(Integer monitor_type, Integer currentPage, Integer pageSize) {
        return doAlertMapper.selectWeekPage(monitor_type, currentPage, pageSize);
    }

}
